//
//  ThemeLabel.m
//  WYThemeManager
//
//  Created by ios on 2017/1/9.
//  Copyright © 2017年 Wy. All rights reserved.
//

#import "ThemeLabel.h"
#import "ThemeManager.h"
@implementation ThemeLabel

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self != nil) {
        [self setColor];
        [self setTextFont];
        
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(themeColorNotification:)
         name:kThemeColorChangeNotification object:nil];
        
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(themeFontNotification:)
         name:kThemeFontChangeNotification object:nil];
        
    }
    return self;
}

-(void)setColor{
    self.textColor = [[ThemeManager shareInstance] getThemeColor];
}

-(void)setTextFont{
    self.font = [UIFont systemFontOfSize:[[ThemeManager shareInstance] getThemeFont]];
}



-(void)themeColorNotification:(NSNotification *)not{
    [self setColor];
}

-(void)themeFontNotification:(NSNotification *)not{
    
    [self setTextFont];
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:kThemeFontChangeNotification];
    [[NSNotificationCenter defaultCenter] removeObserver:kThemeColorChangeNotification];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
